package listbyorder.access701_800.test784;

import java.util.ArrayList;
import java.util.List;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/8/21 17:35
 */
public class Solution1 {

    List<String> res = new ArrayList<>();

    public List<String> letterCasePermutation(String S) {
        if (S == null || S.equals("")) return res;
        int n = S.length();
        char[] cs = new char[n];
        dfs(S.toCharArray(), 0, cs);
        return res;
    }

    private void dfs(char[] ss, int c, char[] cs) {
        if (c == ss.length) {
            res.add(new String(cs));
            return;
        }
        // 首先不考虑改变
        cs[c] = ss[c];
        dfs(ss, c + 1, cs);
        if (Character.isLetter(ss[c])) {
            // 转化
            cs[c] = (char) (ss[c] ^ (1 << 5));
            dfs(ss, c + 1, cs);
        }
    }
}
